/*
 * @Description: 自定义底部tabbar
 * @Author: yiling (315800015@qq.com)
 * @Date: 2021-05-21 17:47:40
 * @LastEditors: liu (1427179517@qq.com)
 * @LastEditTime: 2022-01-24 20:33:48
 * @FilePath: \xiangmu-app\src\store\tabBar.js
 */

const state = {
  list: [], // 底部tabBar数组
  active: 0, // 当前选中的索引
}

state.list = [
  {
    iconPath: require('@/static/tabBar/home.png'),
    selectedIconPath: require('@/static/tabBar/home_active.png'),
    text: '首页',
    customIcon: false,
    pagePath: '/pages/index/index',
  },
  {
    iconPath: require('@/static/tabBar/user.png'),
    selectedIconPath: require('@/static/tabBar/user_active.png'),
    text: '我的',
    customIcon: false,
    pagePath: '/pages/center/center',
  },
]

const getters = {
  active: (state) => {
    console.log('state.active=', state)
    return state.active
  },
  list: (state) => state.list,
}

const mutations = {
  SET_ACTIVE(state, val) {
    state.active = val
    console.log('vuex SET_ACTIVE===', state, val, Date.now())
  },
  SET_LIST(state, val) {
    state.list = val
    console.log('vuex SET_LIST===', state, val, Date.now())
  },
}

export default {
  namespaced: true,
  state,
  getters,
  mutations,
}
